package chenji.itemeditor.help;

import java.util.LinkedHashSet;

import org.bukkit.entity.Player;

import com.google.common.collect.Sets;

public class HelpPage implements Cloneable {
	LinkedHashSet<HelpLine> set = Sets.newLinkedHashSet();

	private HelpPage(LinkedHashSet<HelpLine> set) {
		this.set = set;
	}

	public HelpPage() {}

	public HelpPage addLine(HelpLine l) {
		this.set.add(l);
		return this;
	}

	public void send(Player p) {
		for (HelpLine line : set) {
			line.send(p);
		}
	}

	public void increase(int loc, String message) {
		int nowloc = 0;
		LinkedHashSet<HelpLine> set = Sets.newLinkedHashSet();
		HelpLine forincrease = new HelpLine(message);
		for (HelpLine hl : this.set) {
			set.add(hl);
			if (loc == nowloc) {
				set.add(forincrease);
			}
			nowloc++;
		}
		this.set = set;
	}

	public HelpPage clone() {
		return new HelpPage(this.set);
	}

}
